package com.ayoka.mvp;

import com.ayoka.R;
import com.ayoka.base.BasePresenter;
import com.ayoka.base.IBaseView;
import com.ayoka.bean.BaseResponse;
import com.ayoka.bean.WechatPaymentBean;
import com.ayoka.http.API;
import com.ayoka.http.OkHttpListener;
import com.jcp.baselibrary.utils.UIUtils;

/**
 * Created by gabriel on 2017/3/5.
 */

public interface MemberMVP {

    interface MemberModel {

    }

    interface IMemberView extends IBaseView {

        void onGetMemberPaymentDataSuccess(WechatPaymentBean wechatPaymentBean);
    }

    class MemberPresenter extends BasePresenter<IMemberView> {


        public void getMemberPaymentData() {
            mViewRef.get().showWaitDialog(UIUtils.getString(R.string.loading));
            API.getMemberPaymentData(this, new OkHttpListener<BaseResponse<WechatPaymentBean>>() {
                @Override
                public void onSuccess(BaseResponse<WechatPaymentBean> response) {
                    if (!isAttached()) return;
                    mViewRef.get().hideWaitDialog();
                    mViewRef.get().onGetMemberPaymentDataSuccess(response.data);
                }

                @Override
                public void onFailure(int errorCode, String errorMessage) {
                    if (!isAttached()) return;
                    mViewRef.get().hideWaitDialog();
                    mViewRef.get().showToast(errorMessage);
                    mViewRef.get().onGetMemberPaymentDataSuccess(null);
                }
            });

        }
    }
}
